/*
 * CrystalMonsterSetup --
 *
 *
 *
 * 2009, Tod E. Kurt, http://todbot.com/blog/
 *
 */



#include "Wire.h"
#include "BlinkM_funcs.h"


// pins used on Arduino
const int sensorRXPin  = 5;
const int sensorTXPin  = 6;
const int irDetectPin  = 8;
const int powerPin     = 12;   // 1k pull-down on pin (but doesn't work)
const int ledPin       = 13;

boolean poweron = false;

void setup()
{
  Serial.begin(19200);
  Serial.println("Crystal Monster Setup starting up...");

  pinMode(powerPin, OUTPUT);
  pinMode(irDetectPin, INPUT);
  pinMode(ledPin, OUTPUT);

  power_on();   // power up main system
  delay(500);  // wait for power to stabilize  
  BlinkM_begin();
  
  Serial.println("Crystal Monster Setup ready. Press a key to setup.");

}

void loop() 
{
  if( Serial.available() ) { 
    int c = Serial.read();
    if( c == 'o' ) {
      BlinkM_stopScript( 0 );
    } 
    else if( c == '0' ) {
      BlinkM_fadeToRGB( 0, 0,0,0 );
    }
    else if( c == 'B' ) { 
      Serial.print("Set startup mode");
      BlinkM_setStartupParams( 0, 0,  0,0,1,0);
    }
    else { 
      Serial.println("unrecognized command");
    }
  }
  delay(100);
}


void power_on() {
  Serial.println("powering on");
  digitalWrite( powerPin, LOW );
  poweron = true;
}
void power_off() {
  Serial.println("powering off");
  poweron = false;
  digitalWrite( powerPin, HIGH );
}



